function g2 = dynamic_g2(T, y, x, params, steady_state, it_, T_flag)
% function g2 = dynamic_g2(T, y, x, params, steady_state, it_, T_flag)
%
% File created by Dynare Preprocessor from .mod file
%
% Inputs:
%   T             [#temp variables by 1]     double   vector of temporary terms to be filled by function
%   y             [#dynamic variables by 1]  double   vector of endogenous variables in the order stored
%                                                     in M_.lead_lag_incidence; see the Manual
%   x             [nperiods by M_.exo_nbr]   double   matrix of exogenous variables (in declaration order)
%                                                     for all simulation periods
%   steady_state  [M_.endo_nbr by 1]         double   vector of steady state values
%   params        [M_.param_nbr by 1]        double   vector of parameter values in declaration order
%   it_           scalar                     double   time period for exogenous variables for which
%                                                     to evaluate the model
%   T_flag        boolean                    boolean  flag saying whether or not to calculate temporary terms
%
% Output:
%   g2
%

if T_flag
    T = hansen.dynamic_g2_tt(T, y, x, params, steady_state, it_);
end
g2_i = zeros(23,1);
g2_j = zeros(23,1);
g2_v = zeros(23,1);

g2_i(1)=1;
g2_i(2)=1;
g2_i(3)=1;
g2_i(4)=1;
g2_i(5)=1;
g2_i(6)=1;
g2_i(7)=1;
g2_i(8)=2;
g2_i(9)=2;
g2_i(10)=2;
g2_i(11)=4;
g2_i(12)=4;
g2_i(13)=4;
g2_i(14)=4;
g2_i(15)=4;
g2_i(16)=4;
g2_i(17)=4;
g2_i(18)=4;
g2_i(19)=5;
g2_i(20)=5;
g2_i(21)=5;
g2_i(22)=6;
g2_i(23)=6;
g2_j(1)=31;
g2_j(2)=91;
g2_j(3)=32;
g2_j(4)=102;
g2_j(5)=97;
g2_j(6)=98;
g2_j(7)=108;
g2_j(8)=49;
g2_j(9)=52;
g2_j(10)=82;
g2_j(11)=1;
g2_j(12)=5;
g2_j(13)=45;
g2_j(14)=7;
g2_j(15)=67;
g2_j(16)=49;
g2_j(17)=51;
g2_j(18)=71;
g2_j(19)=1;
g2_j(20)=8;
g2_j(21)=78;
g2_j(22)=13;
g2_j(23)=73;
g2_v(1)=(-(params(1)*(1+y(10)-params(2))*(-1)/(y(9)*y(9))));
g2_v(2)=g2_v(1);
g2_v(3)=(-(params(1)*1/y(9)));
g2_v(4)=g2_v(3);
g2_v(5)=(-(params(1)*(1+y(10)-params(2))*(-((-y(3))*(y(9)+y(9))))/(y(9)*y(9)*y(9)*y(9))));
g2_v(6)=(-(params(1)*(-y(3))/(y(9)*y(9))));
g2_v(7)=g2_v(6);
g2_v(8)=(-((-(T(7)*(y(5)+y(5))))/(y(5)*y(5)*y(5)*y(5))));
g2_v(9)=(-((y(5)*(1-params(3))*(-(1/params(4)))-T(1))/(y(5)*y(5))));
g2_v(10)=g2_v(9);
g2_v(11)=(-(T(4)*y(7)*getPowerDeriv(y(1),params(3),2)));
g2_v(12)=(-(T(6)*T(8)));
g2_v(13)=g2_v(12);
g2_v(14)=(-(T(4)*T(5)));
g2_v(15)=g2_v(14);
g2_v(16)=(-(T(3)*getPowerDeriv(y(5),1-params(3),2)));
g2_v(17)=(-(T(2)*T(8)));
g2_v(18)=g2_v(17);
g2_v(19)=(-((-((-(params(3)*y(8)))*(y(1)+y(1))))/(y(1)*y(1)*y(1)*y(1))));
g2_v(20)=(-((-params(3))/(y(1)*y(1))));
g2_v(21)=g2_v(20);
g2_v(22)=(-(params(5)*(-1)/(y(2)*y(2))));
g2_v(23)=(-1)/(y(7)*y(7));
g2 = sparse(g2_i,g2_j,g2_v,6,121);
end
